home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / ptimer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-10  |  674 b   |  43 lines

  1. #ifndef __PTIMER_H
  2. #define __PTIMER_H
  3.  
  4. #ifndef __DOS_H
  5. #include <dos.h>
  6. #endif
  7.  
  8.     class timer
  9.      { volatile static long t;
  10.        typedef    void interrupt (*isr) (...);
  11.        isr oldvec1c;
  12.  
  13.        static void interrupt handler()
  14.      {
  15.        t++;
  16.      };
  17.  
  18.        friend long programtime();
  19.        public:
  20.        timer()
  21.        {
  22.  
  23.     oldvec1c=getvect(0x1c);
  24.     setvect(0x1c,(isr) timer::handler);
  25.        }
  26.  
  27.  
  28.        ~timer(){
  29.      setvect(0x1c,oldvec1c);
  30.        }
  31.     operator long() ;
  32.  
  33.      };
  34.  
  35. //
  36. // Time after start of the program in syshem "ticks"
  37. // (1 tick ~= 55 ms)
  38.   
  39.    inline long programtime()
  40.       {return timer::t;}
  41.  
  42. #endif __PTIMER_H
  43.